import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';

@Injectable()
export class NavService {
    constructor(@InjectModel('Nav') private readonly navModel) {}
    async find(where = {}, sort = { sort: -1, createdTime: -1 }, fields = null) {
        return await this.navModel.find(where, fields).sort(sort);
    }
    async create(navInfo) {
        return await this.navModel.create(navInfo);
    }
    async update(navInfo) {
        return await this.navModel.updateOne({ _id: navInfo._id }, navInfo);
    }
    async delete(navInfo) {
        return await this.navModel.deleteOne(navInfo);
    }
    getModel() {
        return this.navModel;
    }
}
